package com.chongdong.controller;

import com.chongdong.service.HuaLiServiceImpl;
import com.chongdong.service.ImbServiceImpl;
import com.chongdong.service.NutriServiceImpl;
import com.chongdong.service.SaasServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data")
public class IndexController {
    @Autowired
    private ImbServiceImpl imbService;
    @Autowired
    private HuaLiServiceImpl huaLiService;
    @Autowired
    private NutriServiceImpl nutriService;
    @Autowired
    private SaasServiceImpl saasService;

    @RequestMapping("/huali/{pageNum}/{pageSize}")
    public String tranferHuali(@PathVariable(value = "pageNum") Integer pageNum, @PathVariable(value = "pageSize") Integer pageSize) throws Exception {
        saasService.transferProviderSaaSData2SaaSPlatform();
        huaLiService.transferProviderHuaLiData2SaaSPlatform();
        huaLiService.trnansferBrandData2SaasPlatform();
        huaLiService.transferCategoryData2Platform();
        huaLiService.transferSysProviderAndBrandRelation();
        //huaLiService.trnsferProductHuaLiData2SaaSPlatform(pageNum, pageSize);
        //huaLiService.trnsferPrdDetailHuaLiData2SaaSPlatform(pageNum, pageSize);
        // huaLiService.trnsferPrdImageHuaLiData2SaaSPlatform(pageNum, pageSize);
        return "redirect:/data/imb/1/5000";
    }

    @RequestMapping("/imb/{pageNum}/{pageSize}")
    public String tranferImb(@PathVariable(value = "pageNum") Integer pageNum, @PathVariable(value = "pageSize") Integer pageSize) throws Exception {
        imbService.transferProviderImbData2SaaSPlatform();
        imbService.trnansferBrandData2SaasPlatform();
        imbService.transferCategoryData2Platform();
        imbService.transferSysProviderAndBrandRelation();
        //imbService.trnsferProductImbData2SaaSPlatform(pageNum, pageSize);
        //imbService.trnsferPrdDetailImbData2SaaSPlatform(pageNum, pageSize);
        //imbService.trnsferPrdImageImbData2SaaSPlatform(pageNum, pageSize);
        return "redirect:/data/nutri/1/5000";
    }

    @RequestMapping("/nutri/{pageNum}/{pageSize}")
    public String tranferNutri(@PathVariable(value = "pageNum") Integer pageNum, @PathVariable(value = "pageSize") Integer pageSize) throws Exception {
        nutriService.transferProviderNutriData2SaaSPlatform();
        nutriService.trnansferBrandData2SaasPlatform();
        nutriService.transferCategoryData2Platform();
        nutriService.transferSysProviderAndBrandRelation();
        // nutriService.trnsferProductNutriData2SaaSPlatform(pageNum, pageSize);
        // nutriService.trnsferPrdDetailNutriData2SaaSPlatform(pageNum, pageSize);
        // nutriService.trnsferPrdImageNutriData2SaaSPlatform(pageNum, pageSize);
        return "redirect:/data/saas/1/5000";
    }

    @RequestMapping("/saas/{pageNum}/{pageSize}")
    public String tranferSaas(@PathVariable(value = "pageNum") Integer pageNum, @PathVariable(value = "pageSize") Integer pageSize) throws Exception {
        //saasService.transferProviderSaaSData2SaaSPlatform();
        saasService.transferBrandData2SaasPlatform();
        saasService.transferCategoryData2Platform();
        saasService.transferSysProviderAndBrandRelation();
        // saasService.transferProductSaaSData2SaaSPlatform(pageNum, pageSize);
        // saasService.transferPrdDetailSaaSData2SaaSPlatform(pageNum, pageSize);
        // saasService.transferPrdImageSaaSData2SaaSPlatform(pageNum, pageSize);
        return "success";
    }
}
